```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>深入理解死锁：预防与解决方案</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            line-height: 1.8;
            color: #333;
            background-color: #fafafa;
        }
        h1, h2, h3, h4, h5, h6 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 700;
            color: #2d3748;
            margin-top: 1.5em;
        }
        .hero {
            background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
            color: white;
            border-radius: 0 0 20px 20px;
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
        }
        .card {
            background: white;
            border-radius: 12px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
            transition: all 0.3s ease;
            border-left: 4px solid #6e8efb;
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        }
        .code-block {
            background: #282c34;
            color: #abb2bf;
            border-radius: 8px;
            font-family: 'Courier New', Courier, monospace;
            position: relative;
        }
        .code-block::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 4px;
            height: 100%;
            background: #6e8efb;
            border-radius: 8px 0 0 8px;
        }
        .visualization {
            background: white;
            border-radius: 12px;
            padding: 2rem;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }
        .icon-box {
            width: 60px;
            height: 60px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 1.5rem;
            flex-shrink: 0;
        }
        .drop-cap::first-letter {
            float: left;
            font-size: 4.5rem;
            line-height: 0.65;
            margin: 0.1em 0.1em 0.1em 0;
            color: #6e8efb;
            font-family: 'Noto Serif SC', serif;
        }
        .divider {
            height: 3px;
            background: linear-gradient(90deg, transparent 0%, #6e8efb 50%, transparent 100%);
            margin: 2rem 0;
            opacity: 0.3;
        }
        .hover-underline {
            position: relative;
            display: inline-block;
        }
        .hover-underline::after {
            content: '';
            position: absolute;
            bottom: -2px;
            left: 0;
            width: 0;
            height: 2px;
            background: #6e8efb;
            transition: width 0.3s ease;
        }
        .hover-underline:hover::after {
            width: 100%;
        }
    </style>
</head>
<body class="min-h-screen">
    <!-- Hero Section -->
    <section class="hero py-20 px-6 md:px-16 lg:px-32">
        <div class="max-w-5xl mx-auto">
            <div class="flex items-center mb-6">
                <div class="icon-box bg-white bg-opacity-20">
                    <i class="fas fa-lock text-white text-2xl"></i>
                </div>
                <h1 class="text-4xl md:text-5xl font-bold text-white">深入理解死锁</h1>
            </div>
            <h2 class="text-2xl md:text-3xl font-semibold text-white opacity-90 mb-8">预防与解决方案</h2>
            <p class="text-lg text-white opacity-85 leading-relaxed max-w-3xl drop-cap">
                在并发编程的世界中，死锁是一种让人头痛的难题。它通常发生在多个线程或进程之间竞争共享资源时，由于资源争夺不当，导致系统陷入僵局，无法继续执行。这不仅会影响系统的性能，更严重时可能会导致整个应用程序的崩溃。
            </p>
            <div class="mt-10 flex flex-wrap gap-4">
                <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full text-white text-sm font-medium">#并发编程</span>
                <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full text-white text-sm font-medium">#系统设计</span>
                <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full text-white text-sm font-medium">#性能优化</span>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="max-w-5xl mx-auto px-6 md:px-16 lg:px-32 py-16">
        <!-- Introduction -->
        <section class="mb-20">
            <div class="flex items-start mb-10">
                <div class="icon-box bg-indigo-100 text-indigo-600">
                    <i class="fas fa-exclamation-triangle text-xl"></i>
                </div>
                <div>
                    <h2 class="text-3xl font-bold mb-4 hover-underline">死锁的定义与成因</h2>
                    <p class="text-gray-700 leading-relaxed">
                        死锁是指在一个多线程或多进程环境中，两个或多个线程或进程因竞争共享资源而陷入互相等待的状态，从而导致所有被涉及的线程或进程都无法继续执行的情况。简单来说，死锁就是系统中的一种僵局状态，各方都在等待对方释放资源，但没有任何一方能够打破这种僵局，导致系统整体停滞。
                    </p>
                </div>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8 mb-12">
                <div class="card p-6">
                    <div class="flex items-center mb-4">
                        <div class="w-10 h-10 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center mr-3">
                            <i class="fas fa-ban"></i>
                        </div>
                        <h3 class="text-xl font-semibold">互斥条件</h3>
                    </div>
                    <p class="text-gray-600">系统中的资源只能被一个线程或进程独占，其他线程或进程不能同时访问这些资源。</p>
                </div>
                <div class="card p-6">
                    <div class="flex items-center mb-4">
                        <div class="w-10 h-10 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center mr-3">
                            <i class="fas fa-pause"></i>
                        </div>
                        <h3 class="text-xl font-semibold">持有并等待条件</h3>
                    </div>
                    <p class="text-gray-600">已经持有某些资源的线程或进程，可以继续申请其他资源，并且在等待过程中保持对已占有资源的控制。</p>
                </div>
                <div class="card p-6">
                    <div class="flex items-center mb-4">
                        <div class="w-10 h-10 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center mr-3">
                            <i class="fas fa-lock"></i>
                        </div>
                        <h3 class="text-xl font-semibold">不可剥夺条件</h3>
                    </div>
                    <p class="text-gray-600">资源不能被强制性地从当前持有它的线程或进程中剥夺，只能由线程或进程主动释放。</p>
                </div>
                <div class="card p-6">
                    <div class="flex items-center mb-4">
                        <div class="w-10 h-10 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center mr-3">
                            <i class="fas fa-circle-notch"></i>
                        </div>
                        <h3 class="text-xl font-semibold">循环等待条件</h3>
                    </div>
                    <p class="text-gray-600">存在一个线程或进程链，链中的每一个线程或进程都在等待下一个线程或进程持有的资源，形成循环等待链。</p>
                </div>
            </div>

            <div class="visualization mb-12">
                <h3 class="text-2xl font-semibold mb-6 text-center">死锁必要条件关系图</h3>
                <div class="mermaid">
                    graph TD
                        A[死锁] --> B[互斥条件]
                        A --> C[持有并等待]
                        A --> D[不可剥夺]
                        A --> E[循环等待]
                        B -->|同时满足| A
                        C -->|同时满足| A
                        D -->|同时满足| A
                        E -->|同时满足| A
                </div>
            </div>
        </section>

        <div class="divider"></div>

        <!-- Common Scenarios -->
        <section class="mb-20">
            <div class="flex items-start mb-10">
                <div class="icon-box bg-indigo-100 text-indigo-600">
                    <i class="fas fa-search text-xl"></i>
                </div>
                <div>
                    <h2 class="text-3xl font-bold mb-4 hover-underline">常见的死锁场景分析</h2>
                    <p class="text-gray-700 leading-relaxed">
                        在多线程编程中，死锁问题往往是隐藏且复杂的，因此理解和分析常见的死锁场景，对于编写健壮的并发代码至关重要。
                    </p>
                </div>
            </div>

            <div class="space-y-8">
                <div class="card p-8">
                    <div class="flex items-center mb-6">
                        <div class="w-12 h-12 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center mr-4">
                            <span class="text-xl font-bold">1</span>
                        </div>
                        <h3 class="text-2xl font-semibold">资源竞争死锁</h3>
                    </div>
                    <div class="grid md:grid-cols-2 gap-8">
                        <div>
                            <h4 class="text-lg font-medium mb-3 text-indigo-600">场景描述</h4>
                            <p class="text-gray-600 mb-4">
                                在多线程环境中，线程需要同时持有多个共享资源才能继续执行。然而，如果线程A和线程B分别持有部分资源，并且同时请求对方持有的资源，就会产生相互等待的局面，导致死锁。
                            </p>
                            <h4 class="text-lg font-medium mb-3 text-indigo-600">示例</h4>
                            <ul class="list-disc pl-5 text-gray-600 space-y-2">
                                <li>线程A持有资源1，并请求资源2</li>
                                <li>线程B持有资源2，并请求资源1</li>
                            </ul>
                        </div>
                        <div>
                            <h4 class="text-lg font-medium mb-3 text-indigo-600">预防措施</h4>
                            <div class="space-y-4">
                                <div class="flex items-start">
                                    <div class="w-6 h-6 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center mt-1 mr-3 flex-shrink-0">
                                        <i class="fas fa-check text-xs"></i>
                                    </div>
                                    <p class="text-gray-600">资源分配顺序一致性：确保所有线程按照相同的顺序请求资源，从而避免循环等待的发生。</p>
                                </div>
                                <div class="flex items-start">
                                    <div class="w-6 h-6 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center mt-1 mr-3 flex-shrink-0">
                                        <i class="fas fa-check text-xs"></i>
                                    </div>
                                    <p class="text-gray-600">避免持有并等待：要求线程在持有资源时不得请求其他资源，或在请求新资源前先释放当前持有的资源。</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="card p-8">
                    <div class="flex items-center mb-6">
                        <div class="w-12 h-12 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center mr-4">
                            <span class="text-xl font-bold">2</span>
                        </div>
                        <h3 class="text-2xl font-semibold">嵌套锁导致的死锁</h3>
                    </div>
                    <div class="grid md:grid-cols-2 gap-8">
                        <div>
                            <h4 class="text-lg font-medium mb-3 text-indigo-600">场景描述</h4>
                            <p class="text-gray-600 mb-4">
                                在嵌套锁的场景中，线程可能会尝试在持有一把锁的同时获取另一把锁。如果两个线程试图以不同的顺序获取锁，就会导致死锁。
                            </p>
                            <h4 class="text-lg font-medium mb-3 text-indigo-600">示例</h4>
                            <ul class="list-disc pl-5 text-gray-600 space-y-2">
                                <li>线程A持有锁L1，尝试获取锁L2</li>
                                <li>线程B持有锁L2，尝试获取锁L1</li>
                            </ul>
                        </div>
                        <div>
                            <h4 class="text-lg font-medium mb-3 text-indigo-600">预防措施</h4>
                            <div class="space-y-4">
                                <div class="flex items-start">
                                    <div class="w-6 h-6 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center mt-1 mr-3 flex-shrink-0">
                                        <i class="fas fa-check text-xs"></i>
                                    </div>
                                    <p class="text-gray-600">统一锁的获取顺序：在代码中明确规定锁的获取顺序，确保所有线程按照相同的顺序获取锁。</p>
                                </div>
                                <div class="flex items-start">
                                    <div class="w-6 h-6 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center mt-1 mr-3 flex-shrink-0">
                                        <i class="fas fa-check text-xs"></i>
                                    </div>
                                    <p class="text-gray-600">锁的层次化：根据锁的重要性划分层次，低层次的锁应先获取，高层次的锁后获取。</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="card p-8">
                    <div class="flex items-center mb-6">
                        <div class="w-12 h-12 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center mr-4">
                            <span class="text-xl font-bold">3</span>
                        </div>
                        <h3 class="text-2xl font-semibold">数据库死锁</h3>
                    </div>
                    <div class="grid md:grid-cols-2 gap-8">
                        <div>
                            <h4 class="text-lg font-medium mb-3 text-indigo-600">场景描述</h4>
                            <p class="text-gray-600 mb-4">
                                数据库中的死锁通常发生在事务处理过程中，两个或多个事务试图以不同的顺序锁定相同的数据行或表，导致死锁。
                            </p>
                            <h4 class="text-lg font-medium mb-3 text-indigo-600">示例</h4>
                            <ul class="list-disc pl-5 text-gray-600 space-y-2">
                                <li>事务A锁定了表1的某行，试图更新表2的另一行</li>
                                <li>事务B锁定了表2的某行，试图更新表1的另一行</li>
                            </ul>
                        </div>
                        <div>
                            <h4 class="text-lg font-medium mb-3 text-indigo-600">预防措施</h4>
                            <div class="space-y-4">
                                <div class="flex items-start">
                                    <div class="w-6 h-6 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center mt-1 mr-3 flex-shrink-0">
                                        <i class="fas fa-check text-xs"></i>
                                    </div>
                                    <p class="text-gray-600">合理设计事务：在事务设计中，确保所有事务按照相同的顺序访问资源，避免循环等待。</p>
                                </div>
                                <div class="flex items-start">
                                    <div class="w-6 h-6 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center mt-1 mr-3 flex-shrink-0">
                                        <i class="fas fa-check text-xs"></i>
                                    </div>
                                    <p class="text-gray-600">短事务：尽量减少事务的持锁时间，避免长时间持有锁导致的死锁。</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <div class="divider"></div>

        <!-- Prevention Strategies -->
        <section class="mb-20">
            <div class="flex items-start mb-10">
                <div class="icon-box bg-indigo-100 text-indigo-600">
                    <i class="fas fa-shield-alt text-xl"></i>
                </div>
                <div>
                    <h2 class="text-3xl font-bold mb-4 hover-underline">死锁的预防策略</h2>
                    <p class="text-gray-700 leading-relaxed">
                        死锁问题在多线程编程和分布式系统中是一个常见且棘手的问题。预防死锁的策略主要围绕着破坏产生死锁的必要条件，即避免系统进入可能导致死锁的状态。
                    </p>
                </div>
            </div>

            <div class="grid md:grid-cols-2 gap-8">
                <div class="card p-6">
                    <div class="flex items-center mb-4">
                        <div class="w-10 h-10 rounded-lg bg-indigo-100 text-indigo-600 flex items-center justify-center mr-4">
                            <i class="fas fa-unlink"></i>
                        </div>
                        <h3 class="text-xl font-semibold">破坏互斥条件</h3>
                    </div>
                    <p class="text-gray-600 mb-4">
                        通过减少资源的互斥性来避免此条件的满足。例如对某些资源进行虚拟化，使得资源可以被多个进程或线程同时使用。
                    </p>
                    <div class="bg-indigo-50 p-4 rounded-lg">
                        <h4 class="font-medium text-indigo-700 mb-2">适用场景</h4>
                        <p class="text-sm text-indigo-600">读多写少的共享资源场景，如缓存系统</p>
                    </div>
                </div>

                <div class="card p-6">
                    <div class="flex items-center mb-4">
                        <div class="w-10 h-10 rounded-lg bg-indigo-100 text-indigo-600 flex items-center justify-center mr-4">
                            <i class="fas fa-hand-holding"></i>
                        </div>
                        <h3 class="text-xl font-semibold">破坏持有并等待条件</h3>
                    </div>
                    <p class="text-gray-600 mb-4">
                        在进入临界区之前，线程需要一次性获取所需的所有资源。如果不能全部获取，则释放已经持有的资源，稍后再尝试获取。
                    </p>
                    <div class="bg-indigo-50 p-4 rounded-lg">
                        <h4 class="font-medium text-indigo-700 mb-2">适用场景</h4>
                        <p class="text-sm text-indigo-600">资源需求可预测的系统，如批处理任务</p>
                    </div>
                </div>

                <div class="card p-6">
                    <div class="flex items-center mb-4">
                        <div class="w-10 h-10 rounded-lg bg-indigo-100 text-indigo-600 flex items-center justify-center mr-4">
                            <i class="fas fa-exchange-alt"></i>
                        </div>
                        <h3 class="text-xl font-semibold">破坏不可剥夺条件</h3>
                    </div>
                    <p class="text-gray-600 mb-4">
                        允许系统在必要时强制剥夺某些资源，并将其分配给其他需要的线程。比如在数据库系统中，可以通过回滚机制中断某些事务。
                    </p>
                    <div class="bg-indigo-50 p-4 rounded-lg">
                        <h4 class="font-medium text-indigo-700 mb-2">适用场景</h4>
                        <p class="text-sm text-indigo-600">事务处理系统，数据库管理系统</p>
                    </div>
                </div>

                <div class="card p-6">
                    <div class="flex items-center mb-4">
                        <div class="w-10 h-10 rounded-lg bg-indigo-100 text-indigo-600 flex items-center justify-center mr-4">
                            <i class="fas fa-project-diagram"></i>
                        </div>
                        <h3 class="text-xl font-semibold">破坏循环等待条件</h3>
                    </div>
                    <p class="text-gray-600 mb-4">
                        对系统中的所有资源进行全局排序，并要求线程按照资源的顺序进行请求。通过统一的顺序避免出现循环等待的情况。
                    </p>
                    <div class="bg-indigo-50 p-4 rounded-lg">
                        <h4 class="font-medium text-indigo-700 mb-2">适用场景</h4>
                        <p class="text-sm text-indigo-600">多线程资源管理系统，如操作系统资源分配</p>
                    </div>
                </div>
            </div>

            <div class="visualization mt-12">
                <h3 class="text-2xl font-semibold mb-6 text-center">预防策略效果对比</h3>
                <div class="mermaid">
                    pie
                        title 死锁预防策略实施难度
                        "破坏互斥条件" : 25
                        "破坏持有并等待" : 35
                        "破坏不可剥夺" : 20
                        "破坏循环等待" : 45
                </div>
            </div>
        </section>

        <div class="divider"></div>

        <!-- Detection & Recovery -->
        <section class="mb-20">
            <div class="flex items-start mb-10">
                <div class="icon-box bg-indigo-100 text-indigo-600">
                    <i class="fas fa-search-plus text-xl"></i>
                </div>
                <div>
                    <h2 class="text-3xl font-bold mb-4 hover-underline">死锁检测与恢复</h2>
                    <p class="text-gray-700 leading-relaxed">
                        死锁检测与恢复是处理死锁问题的一种策略，特别是在无法完全避免死锁的复杂系统中。这种策略允许系统在出现死锁时检测并识别死锁的存在，然后采取措施恢复系统的正常运行。
                    </p>
                </div>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-12">
                <div class="card p-6">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-project-diagram text-indigo-600 mr-3"></i>
                        资源分配图算法
                    </h3>
                    <p class="text-gray-600 mb-4">
                        这种方法通过构建资源分配图来检测死锁。在图中，节点表示进程或资源，边表示资源的分配或请求。检测死锁的关键在于寻找图中的循环。
                    </p>
                    <div class="code-block p-4 rounded-lg text-sm">
                        <span class="text-purple-400">function</span> <span class="text-blue-400">detectDeadlock</span>() {
                            <span class="text-gray-500">// 构建资源分配图</span>
                            <span class="text-gray-500">// 检测图中是否存在环</span>
                            <span class="text-gray-500">// 返回检测结果</span>
                        }
                    </div>
                </div>

                <div class="card p-6">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-user-shield text-indigo-600 mr-3"></i>
                        银行家算法变种
                    </h3>
                    <p class="text-gray-600 mb-4">
                        该算法通过模拟资源分配过程，检查当前系统状态是否安全。如果检测到不安全状态，表明存在死锁。
                    </p>
                    <div class="code-block p-4 rounded-lg text-sm">
                        <span class="text-purple-400">function</span> <span class="text-blue-400">bankersAlgorithm</span>() {
                            <span class="text-gray-500">// 计算可用资源</span>
                            <span class="text-gray-500">// 检查系统是否处于安全状态</span>
                            <span class="text-gray-500">// 如果安全则分配，否则拒绝</span>
                        }
                    </div>
                </div>
            </div>

            <div class="bg-indigo-50 rounded-xl p-8">
                <h3 class="text-2xl font-semibold mb-6 text-indigo-700">恢复策略比较</h3>
                <div class="overflow-x-auto">
                    <table class="w-full">
                        <thead>
                            <tr class="text-left border-b-2 border-indigo-100">
                                <th class="pb-3 text-indigo-700">策略</th>
                                <th class="pb-3 text-indigo-700">优点</th>
                                <th class="pb-3 text-indigo-700">缺点</th>
                                <th class="pb-3 text-indigo-700">适用场景</th>
                            </tr>
                        </thead>
                        <tbody class="divide-y divide-indigo-100">
                            <tr>
                                <td class="py-3 font-medium">回滚</td>
                                <td class="py-3 text-gray-600">保证数据一致性</td>
                                <td class="py-3 text-gray-600">可能导致性能损失</td>
                                <td class="py-3 text-gray-600">数据库系统</td>
                            </tr>
                            <tr>
                                <td class="py-3 font-medium">终止进程</td>
                                <td class="py-3 text-gray-600">快速解决问题</td>
                                <td class="py-3 text-gray-600">可能丢失工作</td>
                                <td class="py-3 text-gray-600">非关键任务</td>
                            </tr>
                            <tr>
                                <td class="py-3 font-medium">资源剥夺</td>
                                <td class="py-3 text-gray-600">灵活处理</td>
                                <td class="py-3 text-gray-600">实现复杂</td>
                                <td class="py-3 text-gray-600">实时系统</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </section>

        <div class="divider"></div>

        <!-- Resource Allocation -->
        <section>
            <div class="flex items-start mb-10">
                <div class="icon-box bg-indigo-100 text-indigo-600">
                    <i class="fas fa-tasks text-xl"></i>
                </div>
                <div>
                    <h2 class="text-3xl font-bold mb-4 hover-underline">合理的资源分配与调度</h2>
                    <p class="text-gray-700 leading-relaxed">
                        合理的资源分配与调度是确保系统高效运行、避免资源竞争和死锁等问题的重要手段。它涉及如何在多任务、多线程或多进程的环境下，公平且有效地分配和管理系统资源。
                    </p>
                </div>
            </div>

            <div class="grid md:grid-cols-3 gap-6 mb-12">
                <div class="card p-6 text-center">
                    <div class="w-16 h-16 mx-auto mb-4 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center">
                        <i class="fas fa-balance-scale text-2xl"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">公平性</h3>
                    <p class="text-gray-600">系统应确保所有任务能够公平地获得资源，避免出现资源饥饿现象。</p>
                </div>
                <div class="card p-6 text-center">
                    <div class="w-16 h-16 mx-auto mb-4 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center">
                        <i class="fas fa-tachometer-alt text-2xl"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">效率</h3>
                    <p class="text-gray-600">系统应最大化资源的利用率，避免资源闲置或浪费。</p>
                </div>
                <div class="card p-6 text-center">
                    <div class="w-16 h-16 mx-auto mb-4 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center">
                        <i class="fas fa-stopwatch text-2xl"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">响应时间</h3>
                    <p class="text-gray-600">系统应尽量缩短任务的响应时间，特别是在实时系统中。</p>
                </div>
            </div>

            <div class="visualization">
                <h3 class="text-2xl font-semibold mb-6 text-center">调度算法比较</h3>
                <div class="mermaid">
                    gantt
                        title 调度算法时间线比较
                        dateFormat  HH:mm
                        axisFormat %H:%M
                        section FCFS
                        任务1 :a1, 09:00, 2h
                        任务2 :a2, after a1, 1h
                        任务3 :a3, after a2, 3h
                        section SJN
                        任务3 :b1, 09:00, 1h
                        任务1 :b2, after b1, 2h
                        任务2 :b3, after b2, 3h
                        section RR
                        任务1 :c1, 09:00, 1h
                        任务2 :c2, after c1, 1h
                        任务3 :c3, after c2, 1h
                        任务1 :c4, after c3, 1h
                        任务2 :c5, after c4, 1h
                </div>
            </div>
        </section>
    </main>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            },
            gantt: {
                barHeight: 30,
                fontSize: 12
            }
        });
    </script>
</body>
</html>
```